﻿using System;
using System.Web.UI.WebControls;
using kunukn.RecommendationEngine.AreaRecommendation.Code.Engine;
using kunukn.RecommendationEngine.AreaRecommendation.Code.Entities;
using kunukn.RecommendationEngine.AreaRecommendation.Code.Web;


namespace kunukn.RecommendationEngine.AreaRecommendation.Controls
{
    /// <summary>
    /// Author: Kunuk Nykjaer
    /// </summary>
    public partial class ItemView : MyControl
    {                
        static readonly Random Rand = new Random();
        static readonly string[] Descriptions = new[]
                             {
                                 " This lovely item {0} has the beautiful paint {1}"
                                ," One of the stunning item {0} with the quality glow {1}"
                                ," Unique handcrafted item {0} with hand made pigmentation {1}"
                                ," Made by the finest quality this item {0} is blessed with the luminosity {1}"
                                ," Only few are left, please hurry to get this item {0} with the dye {1}"
                                ," Special rare item {0} with the hue {1}"
                             };

        static string GetItemDescription()
        {
            return Descriptions[Rand.Next(Descriptions.Length)];            
        }

        protected void Page_Load(object sender, EventArgs e)
        {           
            Item currentItem = base.GetCurrentItem();
            Tracker.TrackEvent(currentItem);

            var itemInfo = new Label();
            if (currentItem == null)
            {
                itemInfo.Text = string.Format("The requested Item was not found");
            }
            else
            {
                var thumbnail = this.LoadThumbnail(currentItem, false);
                panelThumbnails.Controls.Add(thumbnail);                                                             
                itemInfo.Text = string.Format(GetItemDescription(), currentItem.Name,
                                           currentItem.Color);
            }

            panelThumbnails.Controls.Add(itemInfo);
        }
    }
}